<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>demo</title>
    <script type="text/javascript" src="../vue.js"></script>
</head>

<body>
    <div id="app">
        <h1>{{count}}</h1>
         <!--  v-on可以简写为@  -->
         <button @click="add">直接累加</button>

         <!-- v-on事件函数 调不调用都可以 加括号只是为了方便传参,不加括号就是不用传参 -->
         <button @click="decrement($event)">每次累减</button>
         <button @click="addN(2,$event)">每次累加2</button>
    </div>
</body>
<script type="text/javascript">
    Vue.config.productionTip = false
    const vm = new Vue({
        el: "#app",
        data() {
            return{
                count: 0
            }
        },
        methods:{
            add(e){
                this.count++
            },
            decrement(e) {
                this.count--;
            },
            addN(n,e){
                this.count += n;
            }
        }
    })
</script>

</html>